from trade import models

def modifyStatus(status, domain=None, nid=None):
  """
  修改域名的状态
  :param domain:
  :param nid:
  :return:
  """
  if nid:
    domain_name = models.DomainList.objects.filter(id=nid).first().domain_name
  else:
    domain_name = domain
  models.DomainList.objects.filter(domain_name=domain_name).update(status=int(status))

def modifyTransaction(tp, domain=None, nid=None):
  """
  修改域名交易类型
  :param tp:
  :param domain_None:
  :param nid:
  :return:
  """
  if nid:
    domain_name = models.DomainList.objects.filter(id=nid).first().domain_name
  else:
    domain_name = domain
  db = models.DomainList.objects.filter(domain_name=domain_name).first()
  db_info = db.domain_info
  db_info_dic = eval(db_info)
  db_info_tp = db_info_dic.get('交易类型')
  ty_s = str(tp)
  if db_info_tp != ty_s:
    db_info_dic['交易类型'] = ty_s
    models.DomainList.objects.filter(domain_name=domain_name).update(domain_info=db_info_dic)
  models.DomainList.objects.filter(domain_name=domain_name).update(transaction_type=tp)